<?php
include_once("Constants.php");
include_once("Entity/survey.php");
include_once("survey_dao_base.php");

class survey_dao extends survey_dao_base
{
	function get_survey_list()
	{
		try
		{
			$dbh = new PDO(Constants::$connectionString, Constants::$username, Constants::$password);
			$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
			$dbh->beginTransaction();

			$aos = array();
			$stmt = $dbh->query("SELECT * FROM survey ORDER BY survey_id DESC");
			$rows = $stmt->fetchAll();
			foreach($rows as $row)
			{
				$s = new survey($row["survey_id"],$row["survey_name"],$row["survey_type_id"],$row["app_id"]);
				$aos[] = $s;
			}

			$dbh->commit();
			$dbh = null;
			
			return $aos;
		}
		catch(PDOException $e)
		{
			echo '<br />' . $e->getMessage();
			$dbh->rollback();
		}	
	}
}
?>